<?php
// +----------------------------------------------------------------------
// | TwoThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.twothink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: YagamiZN 
// +----------------------------------------------------------------------

namespace app\admin\controller;
/**
 * 文件上传类
 */

class FileUpload extends Base {
    /**
     * 上传图片
     */
    public function uploadPictureList(){
        /* 调用文件上传组件上传文件 */
        $file = request()->file('picture');
        if (empty($file)) {
            return ['code'=>300,'msg'=>'请选择 图片'];
        }else{
            $info = $file->validate([
                'ext' => config('picture_upload.ext'),
    			'size' =>  config('picture_upload.size')
            ])->move(config('picture_upload.rootPath'));
            dump($info);
            exit();
            if($info){
                //输出 20160820/42a79759f284b767dfcb2a0197904287.jpg
                //echo $info->getSaveName();
                return json(['code'=>200,'msg'=>'上传成功','pictureName'=>$info->getSaveName()]);
            }else{
                return json(['code'=>400,'msg'=>$file->getError()]);
            }
        }
    }
}
